#include <Arduino.h>
#include "Button.h"
#include "Menu_Ctrl.h"
#include "Led.h"
#include "WatchDog.h"


void setup() 
{
  // put your setup code here, to run once:
  Serial.begin(115200);
  delay(10);
  
  Serial.printf("ESP32 HEAP %d\r\n", esp_get_free_heap_size());

  Button_Init();

  Serial.printf("ESP32 HEAP %d\r\n", esp_get_free_heap_size());

  Led_Init();//LED初始化

  Serial.printf("ESP32 HEAP %d\r\n", esp_get_free_heap_size());

  WatchDog_Init();

  Serial.println("loop start");
}

void loop()
 {
  // put your main code here, to run repeatedly:
  Feed_Dog();

  uint8_t button_state = Get_Button_State();
  if(button_state != 0)
  {
    Serial.printf("Button ESP32 HEAP1 %d\r\n", esp_get_free_heap_size());
    Serial.printf("button %d\r\n", button_state);
  }

  menu_proc(button_state);

  // Led_Open();

  // delay(1000);

  // Led_Close();

  // delay(1000);

  Feed_Dog();
}